package com.aptemo.webetek.client.widgets.scoreboard;

import com.aptemo.webetek.client.widgets.CurrencyWidget;
import com.aptemo.webetek.client.widgets.NumberWidget;
import com.aptemo.webetek.shared.UserBean;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.SpanElement;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;

public class TeamStandingsRow
		extends Composite
{

	interface TeamStandingsRowUiBinder extends UiBinder<Widget, TeamStandingsRow>
	{
	}

	private static TeamStandingsRowUiBinder	uiBinder	= GWT.create(TeamStandingsRowUiBinder.class);

	@UiField
	SpanElement								titleField;

	@UiField
	CurrencyWidget							earningsField;

	@UiField
	NumberWidget							wonField;

	@UiField
	NumberWidget							placedField;

	public TeamStandingsRow(UserBean item)
	{
		initWidget(uiBinder.createAndBindUi(this));

		// Double earnings = item.getEarnings();

		NumberFormat fmt = NumberFormat.getCurrencyFormat("EUR");

		titleField.setInnerText(item.getEmail());

		// if (item.getStatistics() == null)
		// {
		// earningsField.setValue(Double.NaN);
		// wonField.setValue(Double.NaN);
		// placedField.setValue(Double.NaN);
		// return;
		// }
		earningsField.setValue(item.getEarnings());
		wonField.setValue(item.getWonBetCnt());
		placedField.setValue(item.getTotalBetCnt());
	}

}
